%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/condition-featured-messages"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 10, 79, 80, 81, 83, 11, 13, 19, 28, 32<br />2: PgSelect[8]<br />3: PgSelectRows[14]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 11, 80, 28, 32<br /><br />ROOT __Item{1}ᐸ14ᐳ[15]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 16, 11, 80, 28, 32<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[16]<br />1: <br />ᐳ: 17, 22, 29<br />2: PgSelect[23]<br />3: Connection[27]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 27, 11, 22, 80, 28, 29, 32, 23<br /><br />ROOT Connection{2}ᐸ23ᐳ[27]<br />1: ConnectionItems[33], PgSelect[39]<br />ᐳ: 38, 47, 48, 50, 49, 51, 52, 53<br />2: PgSelectRows[41]<br />ᐳ: 40, 42, 43"):::bucket
    Bucket6("Bucket 6 (listItem)<br />Deps: 50, 11<br /><br />ROOT __Item{6}ᐸ33ᐳ[44]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 45, 11<br /><br />ROOT PgSelectSingle{6}ᐸmessagesᐳ[45]<br />1: <br />ᐳ: 54, 57<br />2: PgSelect[58]<br />3: PgSelectRows[63]<br />ᐳ: First[62], PgSelectSingle[64]"):::bucket
    Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 46, 45, 11, 56<br /><br />ROOT Edge{6}[46]"):::bucket
    Bucket9("Bucket 9 (nullableBoundary)<br />Deps: 64<br /><br />ROOT PgSelectSingle{7}ᐸusersᐳ[64]"):::bucket
    Bucket10("Bucket 10 (nullableBoundary)<br />Deps: 45, 11<br /><br />ROOT PgSelectSingle{6}ᐸmessagesᐳ[45]<br />1: <br />ᐳ: 67, 69<br />2: PgSelect[70]<br />3: PgSelectRows[75]<br />ᐳ: First[74], PgSelectSingle[76]"):::bucket
    Bucket11("Bucket 11 (nullableBoundary)<br />Deps: 76<br /><br />ROOT PgSelectSingle{10}ᐸusersᐳ[76]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket6
    Bucket6 --> Bucket7 & Bucket8
    Bucket7 --> Bucket9
    Bucket8 --> Bucket10
    Bucket10 --> Bucket11

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸforumsᐳ<br />More deps:<br />- Object[11]"]]:::plan
    Lambda13{{"Lambda[13∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'INHERIT' ]ᐳ[79]"}}:::plan
    Lambda13 --> PgSelect8
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 5"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    PgSelectRows14[["PgSelectRows[14∈0] ➊"]]:::plan
    PgSelect8 --> PgSelectRows14
    __InputObject19{{"__InputObject[19∈0] ➊<br />More deps:<br />- Constantᐸtrueᐳ[81]"}}:::plan
    ApplyInput28{{"ApplyInput[28∈0] ➊<br />Dependents: 2"}}:::plan
    __InputObject19 --> ApplyInput28
    Lambda32{{"Lambda[32∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />Dependents: 2<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[83]"}}:::plan
    __Item15[/"__Item[15∈1]<br />ᐸ14ᐳ"\]:::itemplan
    PgSelectRows14 ==> __Item15
    PgSelectSingle16{{"PgSelectSingle[16∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item15 --> PgSelectSingle16
    PgSelect23[["PgSelect[23∈2]<br />ᐸmessages+1ᐳ<br />More deps:<br />- Object[11]<br />- Constantᐸ5ᐳ[80]<br />- ApplyInput[28]<br />- Lambda[32]"]]:::plan
    PgClassExpression22{{"PgClassExpression[22∈2]<br />ᐸ__forums__.”id”ᐳ"}}:::plan
    PgClassExpression29{{"PgClassExpression[29∈2]<br />ᐸ__forums__...chived_at”ᐳ"}}:::plan
    PgClassExpression22 & PgClassExpression29 --> PgSelect23
    Connection27[["Connection[27∈2]<br />ᐸ23ᐳ<br />More deps:<br />- Constantᐸ5ᐳ[80]"]]:::plan
    PgSelect23 --> Connection27
    PgClassExpression17{{"PgClassExpression[17∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle16 --> PgClassExpression17
    PgSelectSingle16 --> PgClassExpression22
    PgSelectSingle16 --> PgClassExpression29
    PgSelect39[["PgSelect[39∈3]<br />ᐸmessages(aggregate)ᐳ<br />More deps:<br />- Object[11]<br />- Constantᐸ5ᐳ[80]<br />- ApplyInput[28]<br />- Lambda[32]"]]:::plan
    PgClassExpression22 & PgClassExpression29 --> PgSelect39
    PgCursor51{{"PgCursor[51∈3]"}}:::plan
    First49{{"First[49∈3]"}}:::plan
    Access50{{"Access[50∈3]<br />ᐸ23.cursorDetailsᐳ"}}:::plan
    First49 & Access50 --> PgCursor51
    PgCursor53{{"PgCursor[53∈3]"}}:::plan
    Last52{{"Last[52∈3]"}}:::plan
    Last52 & Access50 --> PgCursor53
    ConnectionItems33[["ConnectionItems[33∈3]"]]:::plan
    Connection27 --> ConnectionItems33
    PageInfo38{{"PageInfo[38∈3]"}}:::plan
    Connection27 --> PageInfo38
    First40{{"First[40∈3]"}}:::plan
    PgSelectRows41[["PgSelectRows[41∈3]"]]:::plan
    PgSelectRows41 --> First40
    PgSelect39 --> PgSelectRows41
    PgSelectSingle42{{"PgSelectSingle[42∈3]<br />ᐸmessagesᐳ"}}:::plan
    First40 --> PgSelectSingle42
    PgClassExpression43{{"PgClassExpression[43∈3]<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle42 --> PgClassExpression43
    Access47{{"Access[47∈3]<br />ᐸ27.hasNextPageᐳ"}}:::plan
    PageInfo38 o--o Access47
    Access48{{"Access[48∈3]<br />ᐸ27.hasPreviousPageᐳ"}}:::plan
    Access47 o--o Access48
    ConnectionItems33 --> First49
    PgSelect23 --> Access50
    ConnectionItems33 --> Last52
    Edge46{{"Edge[46∈6]"}}:::plan
    __Item44[/"__Item[44∈6]<br />ᐸ33ᐳ"\]:::itemplan
    PgCursor56{{"PgCursor[56∈6]"}}:::plan
    __Item44 & PgCursor56 --> Edge46
    __Item44 & Access50 --> PgCursor56
    ConnectionItems33 ==> __Item44
    PgSelectSingle45{{"PgSelectSingle[45∈6]<br />ᐸmessagesᐳ"}}:::plan
    __Item44 --> PgSelectSingle45
    PgSelect58[["PgSelect[58∈7]<br />ᐸusersᐳ<br />More deps:<br />- Object[11]"]]:::plan
    PgClassExpression57{{"PgClassExpression[57∈7]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression57 --> PgSelect58
    PgClassExpression54{{"PgClassExpression[54∈7]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle45 --> PgClassExpression54
    PgSelectSingle45 --> PgClassExpression57
    First62{{"First[62∈7]"}}:::plan
    PgSelectRows63[["PgSelectRows[63∈7]"]]:::plan
    PgSelectRows63 --> First62
    PgSelect58 --> PgSelectRows63
    PgSelectSingle64{{"PgSelectSingle[64∈7]<br />ᐸusersᐳ"}}:::plan
    First62 --> PgSelectSingle64
    PgClassExpression66{{"PgClassExpression[66∈9]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle64 --> PgClassExpression66
    PgClassExpression68{{"PgClassExpression[68∈9]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression66 o--o PgClassExpression68
    PgSelect70[["PgSelect[70∈10]<br />ᐸusersᐳ<br />More deps:<br />- Object[11]"]]:::plan
    PgClassExpression69{{"PgClassExpression[69∈10]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression69 --> PgSelect70
    PgClassExpression67{{"PgClassExpression[67∈10]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgClassExpression54 o--o PgClassExpression67
    PgSelectSingle45 --> PgClassExpression69
    First74{{"First[74∈10]"}}:::plan
    PgSelectRows75[["PgSelectRows[75∈10]"]]:::plan
    PgSelectRows75 --> First74
    PgSelect70 --> PgSelectRows75
    PgSelectSingle76{{"PgSelectSingle[76∈10]<br />ᐸusersᐳ"}}:::plan
    First74 --> PgSelectSingle76
    PgClassExpression77{{"PgClassExpression[77∈11]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle76 --> PgClassExpression77
    PgClassExpression78{{"PgClassExpression[78∈11]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression77 o--o PgClassExpression78

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Lambda13,PgSelectRows14,__InputObject19,ApplyInput28,Lambda32 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item15,PgSelectSingle16 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression17,PgClassExpression22,PgSelect23,Connection27,PgClassExpression29 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,ConnectionItems33,PageInfo38,PgSelect39,First40,PgSelectRows41,PgSelectSingle42,PgClassExpression43,Access47,Access48,First49,Access50,PgCursor51,Last52,PgCursor53 bucket3
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item44,PgSelectSingle45,Edge46,PgCursor56 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression54,PgClassExpression57,PgSelect58,First62,PgSelectRows63,PgSelectSingle64 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgClassExpression66,PgClassExpression68 bucket9
    classDef bucket10 stroke:#ffff00
    class Bucket10,PgClassExpression67,PgClassExpression69,PgSelect70,First74,PgSelectRows75,PgSelectSingle76 bucket10
    classDef bucket11 stroke:#00ffff
    class Bucket11,PgClassExpression77,PgClassExpression78 bucket11

